import request from '../index';
import { DOWNLOAD_TEMTEMPLATE } from '@/service/apis/api';

const financeUrl = '/finance-server';
const orderUrl = '/order-server';
const orderUrl1 = 'api/order-server';
const baseUrl = '/base-server';
const statisticsUrl = '/statistics-server';


// 财务概况

// 电站运营商列表
export const URL_PAGINGOPERATORTOTALINFO = `${statisticsUrl}/historyOrder/pagingOperatorTotalInfo`;
export const pagingOperatorTotalInfo = (params: any, pages: any) => {
  return request({
    url: `${statisticsUrl}/historyOrder/pagingOperatorTotalInfo`,
    params: { form: params, pages: pages },
  });
};

// 电站运营商列表导出
export const EXPORT_OPERATORTOTALINFO = `${statisticsUrl}/historyOrder/exportOperatorTotalInfo`;

// 企业用户列表
export const pagingUserTotalInfo = (params: any, pages: any) => {
  return request({
    url: `${statisticsUrl}/historyOrder/pagingUserTotalInfo`,
    params: { form: params, pages: pages },
  });
};

// 企业用户列表导出
export const EXPORT_USERTOTALINFO = `${statisticsUrl}/historyOrder/exportUserTotalInfo`;

// 电站运营商总统计(渠道)
export const getUserTotalInfo = (params: any) => {
  return request({
    url: `${statisticsUrl}/historyOrder/getUserTotalInfo`,
    params: { form: params },
  });
};

// 财务概况电站运营商占位总统计
export const getOccupyTotalInfo = (params: any) => {
  return request({
    url: `${orderUrl}/occupyOrderUser/getOccupyTotalInfo`,
    params: { form: params },
  });
};

// 查询所有账户汇总余额信息
export const getAccountBalance = (params: any) => {
  return request({
    url: `${financeUrl}/account/getAccountBalance`,
    params: { form: params },
  });
};

// 财务概况电站运营商占位总统计
export const getOccupyUserTotalInfo = (params: any) => {
  return request({
    url: `${orderUrl}/occupyOrderUser/getUserTotalInfo`,
    params: { form: params },
  });
};

// 财务概况 运营商占位订单分页查询
export const pagingOperaOccupy = (params: any, pages: any) => {
  return request({
    url: `${orderUrl}/occupyOrderUser/pagingOperaOccupy`,
    params: { form: params, pages: pages },
  });
};

// 运营商占位订单导出
export const EXPORT_OPERAOCCUPY = `${orderUrl}/occupyOrderUser/exportOperaOccupy`;

// 财务概况 用户占位订单分页查询
export const pagingUserOccupy = (params: any, pages: any) => {
  return request({
    url: `${orderUrl}/occupyOrderUser/pagingUserOccupy`,
    params: { form: params, pages: pages },
  });
};

// 用户占位订单导出
export const EXPORT_USEROCCUPY = `${orderUrl}/occupyOrderUser/exportUserOccupy`;


// 电桩充电汇总
export const pagingOperatorEquipmentInfo = (params: any, pages: any) => {
  return request({
    url: `${statisticsUrl}/historyOrder/pagingOperatorEquipmentInfo`,
    params: { form: params, pages: pages },
  });
};

// 企业用户列表导出
export const EXPORT_OPERATOREQUIPMENTINFO = `${statisticsUrl}/historyOrder/exportOperatorEquipmentInfo`;

// 充电订单列表(单个运营商)
export const pagingStationTotalSeq = (params: any, pages: any) => {
  return request({
    url: `${statisticsUrl}/historyOrder/pagingStationTotalSeq`,
    params: { form: params, pages: pages },
  });
};

// 充电订单列表(单个运营商)导出
export const EXPORT_STATINTOTALSEQ = `${statisticsUrl}/historyOrder/exportStationTotalSeq`;

// 电站运营商总统计(运营商)
export const getStationTotalInfo = (params: any) => {
  return request({
    url: `${statisticsUrl}/historyOrder/getStationTotalInfo`,
    params: { form: params },
  });
};

// 充电订单列表(单个企业)
export const pagingUserTotalSeq = (params: any, pages: any) => {
  return request({
    url: `${statisticsUrl}/historyOrder/pagingUserTotalSeq`,
    params: { form: params, pages: pages },
  });
};

// 充电订单列表(单个企业)导出
export const EXPORT_USERTOTALSEQ = `${statisticsUrl}/historyOrder/exportUserTotalSeq`;

// 分页查询账户信息
export const pagingUserAccount = (params: any, pages: any) => {
  return request({
    url: `${financeUrl}/account/pagingUserAccount`,
    params: { form: params, pages: pages },
  });
};

// 导出账户信息
export const EXPORT_USERACCOUNT = `${financeUrl}/account/exportUserAccount`;

// 分页查询账户信息
export const pagingAccountFlow = (params: any, pages: any) => {
  return request({
    url: `${financeUrl}/account/pagingAccountFlow`,
    params: { form: params, pages: pages },
  });
};

export const queryCompanyConfig = (params: any) => {
  return request({
    url: `${baseUrl}/org/queryCompanyConfig`,
    params: { form: params },
  });
};

export const queryOrgConfig = (params: any) => {
  return request({
    url: `${baseUrl}/org/queryOrgConfig`,
    params: { form: params },
  });
};


// 导出所有账户流水
export const EXPORT_FINANCEFLOW = `${financeUrl}/account/exportFinanceFlow`;

// 分页查询所有账户流水
export const URL_PAGINGALLACCOUNTFLOW = `${financeUrl}/account/pagingAllAccountFlow`;
export const pagingAllAccountFlow = (params: any, pages: any) => {
  return request({
    url: `${financeUrl}/account/pagingAllAccountFlow`,
    params: { form: params, pages: pages },
  });
};


// 导出所有账户流水
export const EXPORT_ALLACCOUNTFLOW = `${financeUrl}/account/exportAllAccountFlow`;

// 获取所有账户流水汇总
export const getAllAccountFlowTotal = (params: any, pages: any) => {
  return request({
    url: `${financeUrl}/account/getAllAccountFlowTotal`,
    params: { form: params, pages: pages },
  });
};

// 消费对账
export const URL_PAGINGCONSUMERINVOICE = `${financeUrl}/account/pagingConsumerInvoice`;
export const pagingConsumerInvoice = (params: any, pages: any) => {
  return request({
    url: `${financeUrl}/account/pagingConsumerInvoice`,
    params: { form: params, pages: pages },
  });
};

// 导出消费对账
export const EXPORT_CONSUMERINVOICE = `${financeUrl}/account/exportConsumerInvoice`;

// 分页查询用户账户每月结余
export const URL_PAGINGACCOUNTPERIODTOTAL = `${financeUrl}/account/pagingAccountPeriodTotal`;
export const pagingAccountPeriodTotal = (params: any, pages: any) => {
  return request({
    url: `${financeUrl}/account/pagingAccountPeriodTotal`,
    params: { form: params, pages: pages },
  });
};

// 分页查询单月用户账户结余
export const URL_PAGINGACCOUNTPERIOD = `${financeUrl}/account/pagingAccountPeriod`;
export const pagingAccountPeriod = (params: any, pages: any) => {
  return request({
    url: `${financeUrl}/account/pagingAccountPeriod`,
    params: { form: params, pages: pages },
  });
};

// 导出单月用户账户结余
export const EXPORT_ACCOUNTPERIOD = `${financeUrl}/account/exportAccountPeriod`;

// 分页查询所有电站运营商分润汇总
export const pagingTotalRecord = (params: any, pages: any) => {
  return request({
    url: `${financeUrl}/shareProfit/pagingTotalRecord`,
    params: { form: params, pages: pages },
  });
};

// 查询所有电站运营商分润汇总信息
export const getTotalInfo = (params: any, pages: any) => {
  return request({
    url: `${financeUrl}/shareProfit/getTotalInfo`,
    params: { form: params, pages: pages },
  });
};

// 根据电站id分页查询电站分润明细
export const URL_PAGINGSTATIONTOTALREACORD = `${financeUrl}/shareProfit/pagingStationRecord`;
export const pagingStationRecord = (params: any, pages: any) => {
  return request({
    url: `${financeUrl}/shareProfit/pagingStationRecord`,
    params: { form: params, pages: pages },
  });
};

// 导出根据电站id分页查询电站分润明细
export const EXPORT_STATIONTOTALREACORD = `${financeUrl}/shareProfit/exportStationRecord`;


// 根据电站运营商id分页查询电站运营商下分润方汇总明细或电站分润汇总明细
// export const URL_PAGINGORGTOTALREACORD = `${financeUrl}/shareProfit/pagingOrgTotalRecord`;
export const pagingOrgTotalRecord = (params: any, pages: any) => {
  return request({
    url: `${financeUrl}/shareProfit/pagingOrgTotalRecord`,
    params: { form: params, pages: pages },
  });
};

// 导出根据电站运营商id分页查询电站运营商下分润方汇总明细或电站分润汇总明细
export const EXPORT_ORGTOTALREACORD = `${financeUrl}/shareProfit/exportOrgTotalRecord`;

// 根据电站运营商id查询分润汇总信息
export const getOrgTotalInfo = (params: any, pages: any) => {
  return request({
    url: `${financeUrl}/shareProfit/getOrgTotalInfo`,
    params: { form: params, pages: pages },
  });
};

// 分页查询单分润方下电站分润信息
export const URL_PAGINGSHARESTATIONREACORD = `${financeUrl}/shareProfit/pagingShareStationRecord`;
export const pagingShareStationRecord = (params: any, pages: any) => {
  return request({
    url: `${financeUrl}/shareProfit/pagingShareStationRecord`,
    params: { form: params, pages: pages },
  });
};

// 导出单分润方下电站分润信息
export const EXPORT_SHARESTATIONREACORD = `${financeUrl}/shareProfit/exportShareStationRecord`;

// 分页查询单分润方下订单明细
export const URL_PAGINGSHAREREACORD = `${financeUrl}/shareProfit/pagingShareRecord`;
export const pagingShareRecord = (params: any, pages: any) => {
  return request({
    url: `${financeUrl}/shareProfit/pagingShareRecord`,
    params: { form: params, pages: pages },
  });
};

// 导出单分润方下订单明细
export const EXPORT_SHAREREACORD = `${financeUrl}/shareProfit/exportShareRecord`;

// 分查询单分润方汇总信息
export const getShareTotalInfo = (params: any, pages: any) => {
  return request({
    url: `${financeUrl}/shareProfit/getShareTotalInfo`,
    params: { form: params, pages: pages },
  });
};

// 场站分润
// 分页查询分润方信息
export const URL_PAGINGSHAREPROFIT = `${financeUrl}/shareProfit/pagingShareProfit`;
export const pagingShareProfit = (params: any, pages: any) => {
  return request({
    url: `${financeUrl}/shareProfit/pagingShareProfit`,
    params: { form: params, pages: pages },
  });
};

// 保存分润方信息
export const shareProfitSave = (params: any) => {
  return request({
    url: `${financeUrl}/shareProfit/save`,
    params: { form: params, successMsg: '1' },
  });
};

// 更新分润方信息
export const shareProfitUpdate = (params: any) => {
  return request({
    url: `${financeUrl}/shareProfit/update`,
    params: { form: params, successMsg: '1' },
  });
};

// 获取分润方信息详情
export const shareProfitUpdateGetById = (params: any) => {
  return request({
    url: `${financeUrl}/shareProfit/getById`,
    params: { form: params },
  });
};

// 删除分润方信息
export const shareProfitDelete = (params: any) => {
  return request({
    url: `${financeUrl}/shareProfit/delete`,
    params: { form: params, successMsg: '2' },
  });
};

// 分页查询分润场站信息
export const URL_PAGINGSHAREPROFITSTATION = `${financeUrl}/shareProfit/pagingShareProfitStation`;
export const pagingShareProfitStation = (params: any, pages: any) => {
  return request({
    url: `${financeUrl}/shareProfit/pagingShareProfitStation`,
    params: { form: params, pages: pages },
  });
};

// 导出分润场站信息
export const EXPORT_SHAREPROFITSTATION = `${financeUrl}/shareProfit/exportShareProfitStation`;

// 开票管理

// 分页查询票务信息详情
export const URL_PAGINGTICKET = `${financeUrl}/ticket/pagingTicket`;
export const pagingTicket = (params: any, pages: any) => {
  return request({
    url: `${financeUrl}/ticket/pagingTicket`,
    params: { form: params, pages: pages },
  });
};

// 导出发票信息
export const EXPORT_TICKET = `${financeUrl}/ticket/exportTicket`;

// 获取票务信息详情
export const ticketGetById = (params: any) => {
  return request({
    url: `${financeUrl}/ticket/getById`,
    params: { form: params },
  });
};

// 更新票务信息
export const ticketUpdate = (params: any) => {
  return request({
    url: `${financeUrl}/ticket/update`,
    params: { form: params, successMsg: '1' },
  });
};

// 分页查询待审批开票记录信息
export const URL_PAGINGTICKETRECORD = `${financeUrl}/ticket/pagingTicketRecord`;
export const pagingTicketRecord = (params: any, pages: any) => {
  return request({
    url: `${financeUrl}/ticket/pagingTicketRecord`,
    params: { form: params, pages: pages },
  });
};

// 导出待审批开票记录信息
export const EXPORT_TICKETRECORD = `${financeUrl}/ticket/exportTicketRecord`;


// 审核开票记录
export const ticketApprove = (params: any) => {
  return request({
    url: `${financeUrl}/ticket/approve`,
    params: { form: params },
  });
};

// 取开票信息详情
export const ticketGetRecordById = (params: any) => {
  return request({
    url: `${financeUrl}/ticket/getRecordById`,
    params: { form: params },
  });
};

// 分页查询开票历史信息
export const URL_PAGINGTICKETRECORDDETAIL = `${financeUrl}/ticket/pagingRecordDetail`;
export const pagingRecordDetail = (params: any, pages: any) => {
  return request({
    url: `${financeUrl}/ticket/pagingRecordDetail`,
    params: { form: params, pages: pages },
  });
};

// 互联互通对账-统计数据
export const getCecTotalInfo = (params: any) => {
  return request({
    url: `${statisticsUrl}/cec/reconciliation/getCecTotalInfo`,
    params: { form: params },
  });
};

// 互联对账结果-导出
export const EXPORT_RECONCILIATION = `${statisticsUrl}/cec/reconciliation/export`;


//  互联对账结果-分页查询
export const URL_RECONCILIATIONQUERYPAGE = `${statisticsUrl}/cec/reconciliation/queryPage`;
export const reconciliationQueryPage = (params: any, pages: any) => {
  return request({
    url: `${statisticsUrl}/cec/reconciliation/queryPage`,
    params: { form: params, pages: pages },
  });
};


// 列表查询-对账中、已关闭账单
export const URL_RECONCILIATIONList = `${orderUrl}/cec/reconciliation/queryPage`;
export const reconciliationList = (params: any, pages: any) => {
  return request({
    url: `${orderUrl}/cec/reconciliation/queryPage`,
    params: { form: params, pages: pages },
  });
};

// 已关闭账单-导出
export const EXPORT_RECONCILCLOSEORDER = `${orderUrl}/cec/reconciliation/exportCloseOrder`;

// 获取关闭对账单所需信息
export const getClosePreInfo = (params: any) => {
  return request({
    url: `${orderUrl}/reconciliation/getClosePreInfo`,
    params: { form: params, },
  });
};

// 关闭对账
export const reconciliationClose = (params: any) => {
  return request({
    url: `${orderUrl}/reconciliation/close`,
    params: { form: params, successMsg: '2' },
  });
};

// 删除
export const reconciliationDelete = (params: any) => {
  return request({
    url: `${orderUrl}/reconciliation/delete`,
    params: { form: params, successMsg: '2' },
  });
};

// 首次发起对账
export const reconciliationSave = (params: any) => {
  return request({
    url: `${orderUrl1}/reconciliation/save`,
    params: { form: params, type: 'import', successMsg: '1' },
  });
};

// 详情重新对账
export const reconciliationUpdate = (params: any) => {
  return request({
    url: `${orderUrl1}/reconciliation/update`,
    params: { form: params, type: 'import', successMsg: '1' },
  });
};

// 争议订单明细列表-表头信息
export const reconciliationOrderInfo = (params: any) => {
  return request({
    url: `${orderUrl}/cec/reconciliation/queryOrderInfo`,
    params: { form: params },
  });
};

// 争议订单明细列表-争议账单、平账账单
// export const URL_RECONCILIATIONList = `${orderUrl}/cec/reconciliation/queryDetailPage`;
export const reconcilQueryDetailPage = (params: any, pages: any) => {
  return request({
    url: `${orderUrl}/cec/reconciliation/queryDetailPage`,
    params: { form: params, pages: pages },
  });
};

// 互联对账结果-导出+已关闭账单-下载对账明细
export const EXPORT_RECONCILDETAILORDER = `${orderUrl}/cec/reconciliation/exportDetailOrder`;


// 处理争议订单
export const reconcilHandleDetail = (params: any) => {
  return request({
    url: `${orderUrl}/reconciliation/handleDetail`,
    params: { form: params, successMsg: '2' },
  });
};

// 已关闭对账重新对账
export const reconcilRestart = (params: any) => {
  return request({
    url: `${orderUrl}/reconciliation/restart`,
    params: { form: params, successMsg: '2' },
  });
};

// 上传模板
export const URL_RECONDOWNLOADS = `${DOWNLOAD_TEMTEMPLATE}/%E4%BA%92%E8%81%94%E4%BA%92%E9%80%9A%E5%AF%B9%E8%B4%A6%E6%A8%A1%E6%9D%BF.xlsx`;
